package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * 实例化Student
 */
public class Test3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class cls = Class.forName("reflect.Student");

        Constructor c = cls.getConstructor();
        Object o = c.newInstance();
        System.out.println(o);

        Constructor c2 = cls.getConstructor(String.class,int.class,char.class);
        Object o2 = c2.newInstance("李四",22,'男');
        System.out.println(o2);
    }
}
